<template>
  <van-picker
  title="更新性别"
  show-toolbar
  :default-index="value"
  :columns="columns"
  @confirm="onConfirm"
  @cancel="$emit('close')"
  />
</template>

<script>
import { Toast } from 'vant'
import { toedituserinfo } from '@/api/getverify'
export default {
  data () {
    return {
      columns: ['男', '女']
    }
  },
  props: {
    value: {
      type: Number,
      required: true
    }
  },

  created () {

  },

  methods: {
    async onConfirm (val, ind) {
      Toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        message: '加载中'
      })
      try {
        console.log(ind)
        console.log('确认')
        const res = await toedituserinfo({
          gender: ind
        })
        console.log(res)
        Toast.success('更新成功')
        this.$emit('input', ind)
        this.$emit('close')
      } catch (error) {
        Toast.fail('更新失败')
      }
    }
  }
}
</script>

<style scoped lang='less'>

</style>
